package leecode

import "math"

func modifiedMatrix(matrix [][]int) [][]int {
	//统计每一列的最大值
	maxNum := make([]int, len(matrix[0]))
	for j := 0; j < len(matrix[0]); j++ {
		temp := math.MinInt
		for i := 0; i < len(matrix); i++ {
			temp = max(temp, matrix[i][j])
		}
		maxNum[j] = temp
	}
	for i := 0; i < len(matrix); i++ {
		for j := 0; j < len(matrix[i]); j++ {
			if matrix[i][j] == -1 {
				matrix[i][j] = maxNum[j]
			}
		}
	}
	return matrix
}
